<template>
  <view>
    <u-navbar title="血脂记录" back-icon-size="34" title-size="36" :border-bottom="false" :background="background" title-color="#222" back-icon-color="#222"></u-navbar>
    <view class="" style="margin-top: 20rpx; background: #fff">
      <view class="" style="display: flex; align-items: center; justify-content: space-between; height: 99rpx; border-bottom: 1rpx solid #e7e7e7">
        <view class="" style="font-size: 28rpx; padding-left: 29rpx">总胆固醇</view>
        <view class="" style="display: flex; align-items: center; padding-right: 35rpx">
          <input type="text" placeholder="请输入" style="font-size: 26rpx; color: #999999; width: 130rpx" v-model="value_one" />
          <text style="font-size: 28rpx; padding-left: 26rpx">mmol/L</text>
        </view>
      </view>
      <view class="" style="display: flex; align-items: center; justify-content: space-between; height: 99rpx; border-bottom: 1rpx solid #e7e7e7">
        <view class="" style="font-size: 28rpx; padding-left: 29rpx">甘油三酯</view>
        <view class="" style="display: flex; align-items: center; padding-right: 35rpx">
          <input type="text" placeholder="请输入" style="font-size: 26rpx; color: #999999; width: 130rpx" v-model="value_two" />
          <text style="font-size: 28rpx; padding-left: 26rpx">mmol/L</text>
        </view>
      </view>
      <view class="" style="display: flex; align-items: center; justify-content: space-between; height: 99rpx; border-bottom: 1rpx solid #e7e7e7">
        <view class="" style="font-size: 28rpx; padding-left: 29rpx">高密度脂蛋白胆固醇</view>
        <view class="" style="display: flex; align-items: center; padding-right: 35rpx">
          <input type="text" placeholder="请输入" style="font-size: 26rpx; color: #999999; width: 130rpx" v-model="value_three" />
          <text style="font-size: 28rpx; padding-left: 26rpx">mmol/L</text>
        </view>
      </view>
      <view class="" style="display: flex; align-items: center; justify-content: space-between; height: 99rpx; border-bottom: 1rpx solid #e7e7e7">
        <view class="" style="font-size: 28rpx; padding-left: 29rpx">低密度脂蛋白胆固醇</view>
        <view class="" style="display: flex; align-items: center; padding-right: 35rpx">
          <input type="text" placeholder="请输入" style="font-size: 26rpx; color: #999999; width: 130rpx" v-model="value_four" />
          <text style="font-size: 28rpx; padding-left: 26rpx">mmol/L</text>
        </view>
      </view>
    </view>
    <!-- BMI -->
    <view class="" style="margin-top: 20rpx; background: #fff">
      <view class="" style="display: flex; align-items: center; justify-content: space-between; height: 99rpx; border-bottom: 1rpx solid #e7e7e7" @tap="show = true">
        <view class="" style="font-size: 28rpx; padding-left: 29rpx">测量日期</view>
        <view class="" style="padding-right: 35rpx">
          <u-icon name="arrow-right" color="#666666" size="28" :label="time" label-pos="left"></u-icon>
        </view>
      </view>
      <!-- <view class=""
				style="display: flex;align-items: center;justify-content: space-between;height: 99rpx;" @tap="show1=true">
				<view class="" style="font-size: 28rpx;padding-left: 29rpx;">
					测量时间
				</view>
				<view class="" style="padding-right: 35rpx;">
					<u-icon name="arrow-right" color="#666666" size="28" :label="times" label-pos="left"></u-icon>
				</view>
			</view> -->
    </view>
    <view class="" style="position: absolute; width: 100%; bottom: 0">
      <view class="btn" @tap="sub">提交数据</view>
    </view>
    <u-picker mode="time" v-model="show" :params="params" @confirm="confirm"></u-picker>
    <u-picker mode="time" v-model="show1" :params="param" @confirm="confirm1"></u-picker>
  </view>
</template>

<script>
export default {
  data() {
    return {
      background: {
        background: '#FFFFFF'
      },
      params: {
        year: true,
        month: true,
        day: true,
        hour: true,
        minute: true,
        second: false
      },
      show: false,
      show1: false,
      param: {
        year: false,
        month: false,
        day: false,
        hour: true,
        minute: true,
        second: false
      },
      time: '',
      times: '',
      value_one: '',
      value_two: '',
      value_three: '',
      value_four: ''
    };
  },
  methods: {
    confirm(e) {
      console.log(e);
      this.time = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute;
    },
    confirm1(e) {
      this.times = e.hour + ':' + e.minute;
    },
    sub() {
      if (this.value_one == '') {
        uni.showToast({
          title: '请输入您的总胆固醇',
          icon: 'none'
        });
      } else if (this.value_two == '') {
        uni.showToast({
          title: '请输入您的甘油三酯',
          icon: 'none'
        });
      } else if (this.value_three == '') {
        uni.showToast({
          title: '请输入您的高密度脂蛋白胆固醇',
          icon: 'none'
        });
      } else if (this.value_four == '') {
        uni.showToast({
          title: '请输入您的低密度脂蛋白胆固醇',
          icon: 'none'
        });
      } else if (this.time == '') {
        uni.showToast({
          title: '请选择您的测量日期',
          icon: 'none'
        });
      } else {
        this.api({
          url: '/api/healthy/addDataFive',
          method: 'post',
          data: {
            value_one: this.value_one,
            value_two: this.value_two,
            value_three: this.value_three,
            value_four: this.value_four,
            measure_time: this.time
          }
        }).then((res) => {
          uni.showToast({
            title: res.msg,
            icon: 'none'
          });
          setTimeout(() => {
            uni.navigateBack();
          }, 1500);
        });
      }
    }
  }
};
</script>

<style>
page {
  background: #f8f8f8;
}
.btn {
  margin: 99rpx 115rpx;
  height: 80rpx;
  background: linear-gradient(180deg, #1a9eff, #0fb8ff);
  border-radius: 40rpx;
  font-size: 32rpx;
  color: #fff;
  text-align: center;
  line-height: 80rpx;
}
</style>
